import java.util.Stack;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 08 - 20
 * Time: 11:50
 */
class MinStack {
    Stack<Integer> minStack;
    Stack<Integer> Stack;

    public MinStack() {
        minStack = new Stack<>();
        Stack = new Stack<>();
    }

    public void push(int val) {
        if(Stack.isEmpty()) {
            minStack.push(val);
            Stack.push(val);
        }else {
            if(val > Stack.peek()) {
                minStack.push(val);
            }else {
                minStack.push(val);
                Stack.push(val);
            }
        }
    }

    public void pop() {
        int num = Stack.peek();
        if(minStack.peek() == num) {
            minStack.pop();
            Stack.pop();
        }else {
            minStack.pop();
        }
    }

    public int top() {
        return minStack.peek();
    }

    public int getMin() {
        return Stack.peek();
    }
}